package com.coding.controller;


import com.coding.dto.RestBean;
import com.coding.pojo.VideoCommentReply;
import com.coding.pojo.VideoCommentReplyRelate;
import com.coding.service.VideoMessageService;
import com.coding.util.CommentInitializer;
import com.coding.vo.UserCommentVo;
import com.coding.vo.UserSendComVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/message")
public class VideoMessageController {

    @Autowired
    VideoMessageService videoMessageService;

    @Autowired
    RedisTemplate<String, Object> redisTemplate;

    @Autowired
    CommentInitializer initializer;

    @RequestMapping("/test")
    public String test() {

        String str = videoMessageService.test();
        return str;

    }




//    发送评论
    @RequestMapping("/send")
    public RestBean sendMessage(UserSendComVo vo) {
        System.out.println("sdasdasdasdasdasdasd");
        System.out.println(vo.toString());
        if (videoMessageService.sendCommnet(vo.getvideoId(), vo.getUserId(), vo.getContent())) {
            return RestBean.success("评论发表成功", "评论发表成功");
        } else {
            return RestBean.failure(404, "服务器繁忙，请稍后");
        }

    }

}
